/* JavaLog - package tracker 
 * 
 * Copyright (C) 2009 Allyson Lima, Diego Pedro, Victor Freire
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software 
 * Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this 
 * program. If not, see <http://www.gnu.org/licenses/>.
 */
package br.edu.ufcg.ccc.javalog.view;

import java.awt.GraphicsEnvironment;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

/** 
 * Abstract class for View classes.
 * @author Allyson Lima, Diego Pedro, Victor Freire
 * @version 22/11/09 
 */
@SuppressWarnings("serial")
public abstract class AbstractView extends JFrame {
	private static final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
	
	protected void thisWindowClosed(WindowEvent evt) {
		WindowManager.getInstance().closeLastWindow();
	}
	
	/**
	 * Automatically sets the default Window event listeners.
	 */
	public AbstractView() {
		this.setMaximizedBounds(env.getMaximumWindowBounds()); // fixes maximizing for Java L&F
		
		this.addWindowListener(new WindowAdapter() {
			public void windowClosed(WindowEvent evt) {
				thisWindowClosed(evt);
			}
		});
	}
	
	protected void maximize() {
		setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);		
	}
	
}
